﻿#pragma once
#include "Common.h"
#include "ObjectPool.h"



// thread cache 是一个哈希构成的自由链表
class ThreadCache {
public:
	//申请和释放内存对象
	void* Allocate(size_t size);
	void Deallocate(void* ptr, size_t size);

	//从中心缓存获取一定数量的对象给thread cache
	void* FetchFromCentralCache(size_t index, size_t size);

	//释放对象时, 链表过长时, 回收内存到中心缓存
	void ListTooLong(FreeList* list, size_t size);


private:
	FreeList _freeLists[NFREELISTS];

};

static thread_local ThreadCache* TlsThreadCache = nullptr;





